package cn.kgc.easybuy.config;

import com.wechat.pay.java.core.RSAAutoCertificateConfig;

public class MyWXpayConfig {
    // 商户号
    private String merchantId = "1606612310";

    // 商户API私钥路径
    private String privateKeyPath = MyWXpayConfig.class.getClassLoader().getResource("apiclient_key.pem").getPath();

    // 商户证书序列号
    private String merchantSerialNumber = "328B40F3A627A7E88A714FF5CA8027BE767EF3F2";

    // 商户APIV3密钥
    private String apiV3key = "hnjyet993603562456bdqn4685030352";

    // 应用程序ID
    private String appid = "wxa738052168ff7dc8";

    // 微信支付回调地址，需修改成内网穿透的域名地址
    private String notifyUrl = "http://3d0cc69c.r37.cpolar.top/api/ali/wxNotify";

    // RSA自动证书配置类
    private RSAAutoCertificateConfig config;

    private static MyWXpayConfig wxPayConfig = new MyWXpayConfig();

    private MyWXpayConfig(){
        // 根据基本参数构建RSAAutoCertificateConfig对象
        config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3key)
                .build();
    }

    public static MyWXpayConfig getInstance(){
        return wxPayConfig;
    }

    // 返回配置对象
    public RSAAutoCertificateConfig getConfig(){
        return config;
    }

    public String getAppid() {
        return this.appid;
    }

    public String getMerchantId() {
        return this.merchantId;
    }

    public String getNotifyUrl() {
        return this.notifyUrl;
    }
}
